﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;
using ComLib.ComFun;

namespace PhotoPrinter
{
    static class Program
    {       
        public static bool m_bTestMode = false;
      
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if (!PrinterService.CreatePrinterService())
            {
                MessageBox.Show("打印服务创建失败!");
                return;
            }
            Process pc = Process.GetCurrentProcess();
            Process[] pcA = Process.GetProcessesByName(Application.ProductName);
            if (pcA.Length > 0)
            {
                for (int i = 0; i < pcA.Length; i++)
                {
                    if (pcA[i].Id != pc.Id)
                    {
                       MessageBox.Show(Application.ProductName + "已运行");
                       return;
                    }
                }
            }        
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (args.Length > 0)
            {
                Application.Run(new FormPrintingService(args[0]));
            }
            else
            {
                Application.Run(new FormPrintingService());
            }
        }
    }
}
